﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ershou.BLL;

public partial class Default2 : System.Web.UI.Page
{
    yh customerSrv = new yh();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["name"] != null)
            {
                TextBox1.Text = Request.QueryString["name"];
                Label5.Text = "注册成功，请登录!";
            }
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            int Id = customerSrv.CheckLogin(TextBox1.Text.Trim(), TextBox2.Text.Trim());
            int Key = customerSrv.CheckLogin2(TextBox1.Text.Trim(), TextBox2.Text.Trim());
            if (Id > 0)
            {
                Session.Clear();      
                if (Key == 3 && RadioButton3.Checked)
                {
                    Session["CustomerId"] = Id;
                    Session["CustomerName"] = TextBox1.Text;
                    Session["Key"] = Key;
                    Response.Redirect("~/Default.aspx");
                }
                else if(Key==2 && RadioButton2.Checked)
                {
                    Session["CustomerId"] = Id;
                    Session["CustomerName"] = TextBox1.Text;
                    Session["Key"] = Key;
                    Response.Redirect("~/Default.aspx");
                }
                else if(Key==1 && RadioButton1.Checked)
                {
                    Session["CustomerId"] = Id;
                    Session["CustomerName"] = TextBox1.Text;
                    Session["Key"] = Key;
                    Response.Redirect("~/Default.aspx");
                }
                else
                {
                    Label5.Text = "用户名或密码错误！";
                }
            }
            else
            {
                Label5.Text = "用户名或密码错误！";
            }
        }
    }
}